/* 检查变位词： 相同字母的重新排列 */
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
int main(void)
{
    int letters[26] = {0};
    char ch;
    bool is_anagrams = true;
    printf("Enter first word: ");
    while ((ch = getchar()) != '\n') {
        if (isalnum(ch))
            letters[tolower(ch) - 'a']++;
    }
    printf("Enter second word: ");
    while ((ch = getchar()) != '\n') {
        if (isalnum(ch))
            letters[tolower(ch) - 'a']--;
    }
    for (int i = 0; i < 26; i++) {
        if (letters[i] != 0) 
            is_anagrams = false;
    }
    printf("The words are%s anagrams.\n", is_anagrams ? "" : " not");
    return 0;
}